<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理页面</title>
<link href="{webroot}theme/admin/css/iframe.css" rel="stylesheet" type="text/css" />
<link href="{webroot}lib/css/jquery.colorpicker.css" rel="stylesheet" type="text/css" />
<link href="{webroot}lib/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<script src="{webroot}lib/js/jquery.js"></script>
<script src="{webroot}lib/js/jquery-migrate-1.1.0.min.js"></script>
<script src="{webroot}lib/js/base.js"></script>
<script src="{webroot}lib/tips/jquery.tips.js"></script>
<script src="{webroot}lib/validator/jquery.validator.js"></script>
<script src="{webroot}lib/validator/zh_CN.js"></script>
<script src="{webroot}lib/js/jquery.livequery.js"></script>
<script src="{webroot}lib/js/jquery.colorpicker.js"></script>
<script src="{webroot}lib/js/jquery.autocomplete.js"></script>
<script src="{webroot}theme/admin/js/admin.js"></script>
<script src="{webroot}lib/dialog/artdialog.js"></script>
<!--[if lt IE 9]>
<script src="{webroot}lib/js/html5.js"></script>
<![endif]-->
<script>
$(function(){
	$("#t8_1").click(function(){$("#rules").css("display","block");})
	$("#t8_0").click(function(){$("#rules").css("display","none");})
})
</script>
</head>
<body>

<div class="layout-center">
	<div class="right_subject">当前位置：栏目 > <a href="sd_model.asp">模型管理</a> > <a href="?act=field&modelid={modelid}">字段管理</a> > <a href="?act=edit&id={id}&modelid={modelid}">编辑字段</a></div>
    <div class="right_body">
        <div class="table_form">
            <form class="formname" method="post">
                <div class="form_group">
                    <div class="form_txt">字段名称：</div>
                    <div class="form_input"><input name="t0" type="text" disabled class="ip"  value="{datadb(0,0)}" size="30" maxlength="20" data-rule="字段名称:required;" /></div>
                </div>
                <div class="form_group">
                    <div class="form_txt">字段别名：</div>
                    <div class="form_input"><input name="t1" type="text" class="ip"  value="{datadb(1,0)}" size="30" maxlength="7" data-rule="字段别名:required;" /></div>
                </div>
                <div class="form_group">
                    <div class="form_txt">字段类型：</div>
                    <div class="form_input">
                        <select name="t2" id="t2" class="ip" disabled>
                        <option value="1"{if datadb(2,0)=1} selected{/if}>单行文本框</option>
                        <option value="2"{if datadb(2,0)=2} selected{/if}>多行文本框</option>
                        <option value="3"{if datadb(2,0)=3} selected{/if}>下拉列表</option>
                        <option value="4"{if datadb(2,0)=4} selected{/if}>单选按钮</option>
                        <option value="5"{if datadb(2,0)=5} selected{/if}>复选框</option>
                        <option value="6"{if datadb(2,0)=6} selected{/if}>HTML编辑器</option>
                        </select>
                    </div>
                </div>
                <div class="form_group{if datadb(2,0)<>1} dis{/if}">
                    <div class="form_txt">表现形式：</div>
                    <div class="form_input">
                        <input type="radio" name="t3" id="t3_1" value="1"{if datadb(3,0)=1} checked{/if} disabled>普通文本
                        <input type="radio" name="t3" id="t3_2" value="2"{if datadb(3,0)=2} checked{/if} disabled>整数
                        <input type="radio" name="t3" id="t3_5" value="5"{if datadb(3,0)=5} checked{/if} disabled>小数
                        <input type="radio" name="t3" id="t3_3" value="3"{if datadb(3,0)=3} checked{/if} disabled>日期
                        <input type="radio" name="t3" id="t3_4" value="4"{if datadb(3,0)=4} checked{/if} disabled>上传
                    </div>
                </div>
                <div class="form_group{if datadb(3,0)<>4} dis{/if}">
                    <div class="form_txt">上传类型：</div>
                    <div class="form_input">
                        <select name="t13" id="t13" class="ip" data-rule="上传类型:required;">
                        <option value="">请选择上传类型</option>
                        <option value="1"{if datadb(13,0)=1} selected{/if}>图片</option>
                        <option value="2"{if datadb(13,0)=2} selected{/if}>附件</option>
                        <option value="3"{if datadb(13,0)=3} selected{/if}>视频</option>
                        <option value="5"{if datadb(13,0)=5} selected{/if}>Flash</option>
                        <option value="4"{if datadb(13,0)=4} selected{/if}>全部类型</option>
                        </select>
                    </div>
                </div>
                <div class="form_group">
                    <div class="form_txt">数据类型：</div>
                    <div class="form_input">
                    <select name="t4" class="ip" disabled>
                    <option value="1"{if datadb(4,0)=1} selected{/if}>文本</option>
                    <option value="2"{if datadb(4,0)=2} selected{/if}>数字</option>
                    <option value="3"{if datadb(4,0)=3} selected{/if}>货币</option>
                    <option value="4"{if datadb(4,0)=4} selected{/if}>日期</option>
                    <option value="5"{if datadb(4,0)=5} selected{/if}>备注</option>
                    </select>
                    </div>
                </div>
                <div class="form_group{if datadb(2,0)<>1} dis{/if}">
                    <div class="form_txt">字段长度：</div>
                    <div class="form_input"><input type="text" name="t5" id="t5" value="{datadb(5,0)}" size="30" maxlength="3" class="ip" data-rule="字段长度:required;integer;range[1~255]" disabled /><span>1-255</span><span for="t5" class="msg-box"></span></div>
                </div>
                <div class="form_group">
                    <div class="form_txt">默认值：</div>
                    <div class="form_input"><input type="text" name="t6" size="30" value="{datadb(6,0)}" maxlength="255" class="ip" /></div>
                </div>
                <div class="form_group{if datadb(2,0)<3 or datadb(2,0)>5} dis{/if}">
                    <div class="form_txt">列表内容：</div>
                    <div class="form_input"><textarea name="t7" id="t7" class="tt" cols="30" rows="6" data-rule="列表内容:required;">{datadb(7,0)}</textarea><span>示范：项目名称|项目值</span><span for="t7" class="msg-box"></span><br><span>一行一个项目</span></div>
                </div>
                <div class="form_group{if datadb(2,0)=6} dis{/if}">
                    <div class="form_txt">是否必填：</div>
                    <div class="form_input">
                        <input type="radio" name="t8" id="t8_1" value="1"{if datadb(8,0)=1} checked{/if}>是
                        {if datadb(4,0)=1 or datadb(4,0)=5}
                        <input type="radio" name="t8" id="t8_0" value="0"{if datadb(8,0)=0} checked{/if}>否
                        {/if}
                    </div>
                </div>
                <div class="form_group{if datadb(8,0)=0} dis{/if}" id="rules">
                    <div class="form_txt">验证规则：</div>
                    <div class="form_input">
                    <select name="t9" class="ip" data-rule="验证规则:required;">
                    <option value="">请选择验证规则</option>
                    {if datadb(4,0)=1 or datadb(2,0)=2}
                    <option value="1"{if datadb(9,0)=1} selected{/if}>不为空</option>
                    {/if}
                    {if datadb(4,0)=1 and datadb(2,0)=1 and datadb(3,0)=1}
                    <option value="4"{if datadb(9,0)=4} selected{/if}>电话</option>
                    <option value="5"{if datadb(9,0)=5} selected{/if}>手机</option>
                    <option value="6"{if datadb(9,0)=6} selected{/if}>邮箱</option>
                    <option value="8"{if datadb(9,0)=8} selected{/if}>邮编</option>
                    <option value="9"{if datadb(9,0)=9} selected{/if}>QQ</option>
                    <option value="10"{if datadb(9,0)=10} selected{/if}>网址</option>
                    {/if}
                    {if datadb(4,0)=2}
                    <option value="2"{if datadb(9,0)=2} selected{/if}>数字</option>
                    {/if}
                    {if datadb(4,0)=3}
                    <option value="3"{if datadb(9,0)=3} selected{/if}>小数</option>
                    {/if}
                    {if datadb(4,0)=4}
                    <option value="7"{if datadb(9,0)=7} selected{/if}>日期</option>
                    {/if}
                    
                    </select>
                    </div>
                </div>
                <div class="form_group">
                    <div class="form_txt">去掉两端空格：</div>
                    <div class="form_input">
                        <input type="radio" name="t10" id="t10_1" value="1"{if datadb(10,0)=1} checked{/if}>是
                        <input type="radio" name="t10" id="t10_0" value="0"{if datadb(10,0)=0} checked{/if}>否
                    </div>
                </div>
                <div class="form_group">
                    <div class="form_txt">字段排序：</div>
                    <div class="form_input">
                        <input name="t11" id="t11" type="text" class="ip" value="{datadb(11,0)}" size="30" maxlength="10" data-rule="字段排序:required;integer;" /><span>数字越小越靠前</span><span for="t11" class="msg-box"></span>
                    </div>
                </div>
                <div class="form_group">
                    <div class="form_txt">状态：</div>
                    <div class="form_input">
                    <input type="radio" name="t12" value="1" id="t12_1"{if datadb(12,0)=1} checked{/if}><label for="t12_1">正常</label>
                    <input type="radio" name="t12" value="0" id="t12_0"{if datadb(12,0)=0} checked{/if}><label for="t12_0">锁定</label>
                    </div>
                </div>

                <div class="form_group">
                    <div class="form_bnt"><input type="submit" value="保存" class="bnt_save"><input type="button" value="返回" class="bnt_normal goback"></div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
$(".formname").validator(
	{
		stopOnError:true,
        theme:'yellow_right_effect',
		ignore:':hidden',
		beforeSubmit:function(){$("input[type='submit']").attr("disabled",true);},
		valid:function(form)
		{
			$.fn.tips({type:'loading',content:'数据提交中'});
			$.ajax(
			{
				url:"?act=editdb&id={id}&modelid={modelid}",
				type:"post",
				data:$(form).serialize(),
				error:function(data){alert(data);},
				success:function(data){
					data=jQuery.parseJSON(data);
					var type="warn";
					if(data.status=="y"){type="ok";}
					$.fn.tips({type:type,content:data.info});
					if(data.status=="y"){setTimeout('location.href="?modelid={modelid}"',1000);}
					else{$("input[type='submit']").attr("disabled",false);}	
				}
			});
		},
		invalid:function(){$("input[type='submit']").attr("disabled",false);}
	}
);
</script>
</body>
</html>